A magnetic disk device generates parity data for write data by an exclusive OR (XOR) operation based on write data. In a magnetic disk device that does not employ the Shingled Magnetic Recording (SMR) system, if parity data is added to write data by On-The-Fly, performance may be adversely affected. In this magnetic disk device, a system in which parity data is added to write data in the background is effective in avoiding that.
When adding parity data to write data in the background, the magnetic disk device reads write data from a particular track, and generates parity data based on the read write data. After that, it writes the generated parity data to a parity sector on the same track as the read write data. At this time, a rotational delay may occur before the parity data is written to the parity sector.
Moreover, in the magnetic disk, if valid parity data is stored in the parity sector, a sector wherein a read error has occurred can be recovered by performing an XOR operation of the write data of sectors other than the sector with the read error, and the valid parity data. In contrast, if no valid parity data is stored in the parity sector, the read-error sector cannot be recovered.
In view of the above, there is a demand for efficiently updating the parity sector to have valid parity data.